using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
namespace DAL
{
    public class PublicAdmins : DAL.DataManager<PublicAdmin>
    {
        private static PublicAdmins Instance = new PublicAdmins();
        static PublicAdmins() { }

        public override string TableName
        {
            get { return @"fstdt_publicadmin"; }
        }

        public static string GetTableName()
        {
            return Instance.TableName;
        }

        protected override void CopyToItem(DataRow Row, PublicAdmin Item)
        {
            Item.Approved = Convert.ToBoolean(Row["Action"]);

            Item.Quote = Quotes.Item(Convert.ToInt64(Row["QuoteID"]));

            Item.User = Users.Item(Convert.ToInt64(Row["UserID"]));
        }

        protected override void CopyFromItem(DataManagerQuery query, PublicAdmin Item)
        {
            query.AddParam("Action", Item.Approved);

            query.AddParam("QuoteID", Item.Quote.ID);

            query.AddParam("UserID", Item.User.ID);
        }

        public static PublicAdmin Item(Int64 id)
        {
            return Instance.GetItem(id);
        }

        public static List<PublicAdmin> All()
        {
            return Instance.GetItems();
        }

        public static void Add(PublicAdmin Item)
        {
            Instance.Insert(Item);
        }

        public static void Save(PublicAdmin Item)
        {
            Instance.Update(Item);
        }
    }

    public class PublicAdmin : DAL.DataManagerRow
    {
        private bool _Action;
        public bool Approved
        {
            get
            {
                return _Action;
            }
            set
            {
                _Action = value;
            }
        }


        private Quote _Quote;
        public Quote Quote
        {
            get
            {
                return _Quote;
            }
            set
            {
                _Quote = value;
            }
        }


        private User _User;
        public User User
        {
            get
            {
                return _User;
            }
            set
            {
                _User = value;
            }
        }
    }
}
